package com.oro.backingbeans;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.oro.domain.Cliente;
import com.oro.service.CustomerService;

public class VisualizzaClientiBean {

	private static final Logger logger = Logger
			.getLogger(InserisciClienteBean.class);

	List<Cliente> clienti;

	@Autowired
	CustomerService customerService;

	public VisualizzaClientiBean() {
		super();
		clienti = new ArrayList<Cliente>();
	}

	public VisualizzaClientiBean(List<Cliente> clienti) {
		super();
		this.clienti = clienti;
	}

	public List<Cliente> getClienti() {
		return clienti;
	}

	public CustomerService getCustomerService() {
		return customerService;
	}

	private Logger getLogger() {
		return logger;
	}

	public void loadAllCustomers() {
		setClienti(customerService.getAllCustomers());
	}

	@PostConstruct
	public void postConstruct() {
		getLogger().info("VisualizzaClientiBean has been constructed.");
	}

	@PreDestroy
	public void preDestroy() {
		getLogger().info("VisualizzaClientiBean is being destroyed.");
	}

	public void setClienti(List<Cliente> clienti) {
		this.clienti = clienti;
	}

	public void setCustomerService(CustomerService customerService) {
		this.customerService = customerService;
	}

}
